<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>${product.productName}</title>
	<link href="/shop/css/shop-top.css" rel="stylesheet" /> 
	<link href="/shop/css/shop-detail.css" rel="stylesheet" /> 
	<link href="/shop/css/shop-footer.css" rel="stylesheet" /> 
	<link href="/shop/css/shop-tuan.css" rel="stylesheet" />
    <link href="/shop/css/shop-common.css" rel="stylesheet" />
    <jsp:include page="/head.jsp" />
	<script type="text/javascript" src="/shop/js/shop-public.js"></script> 
	<script type="text/javascript" src="/js/jquery.min.js"></script>
	<script type="text/javascript" src="/shop/js/shop-layer/layer.js"></script>
  </head>
  
 <body>
 <c:import url="/news-class.do?mb=header" /> 
<%@ include file="/shop/jsps/top.jsp"  %>
<%@ include file="jsps/hader.jsp" %>
  <div class="yershop_wrapper">
   <div class="menu-wrapper"> 
   <div class="nava"> 
    <div class="nav-all"> 
     <div class="all_class" id="all-class"> 
      <h2 style="margin-top: 0px;"><span><a href="/shop.html" target="_self" style="text-decoration:none;font-size: 18px;">首页</a></span></h2> 
     </div>
    </div>  
     <ul class="menu"> 
     <li> <a href="cart.do" target="_self">购物车</a> </li>
    </ul> 
    </div>
   </div> 
   <!-- /菜单 --> 
   <!-- 主体 --> 
   <div class="commom_wrapper"> 
    <div class="main"> 
     
     <div class="details"> 
      <div class="details_left"> 
       <!-- 商品描述--> 
       <div class="details_left_top"> 
        <!-- jqzoom--> 
        <div id="zoom"> 
         <div class="jqzoom" id="spec-n1">
          <img src="${product.productImgs}" style="height: 350px; width: 350px;">
         </div> 
        </div>
        <!-- wwww over--> 
        <!-- 商品参数--> 
        <div class="dl_goods_info" style="z-index: 2"> 
         <h2 class="dginfo_h2"> ${product.productName}</h2>
         
         <p>价格：<span class="dginfo_price">￥<em class="price" id="resetprice"> ${product.productPrice1}</em></span></p> 
         <ul class="dginfo_info"> 
          <li>销量：${product.productSales}</li> 
          <li class="dginfo_info_last">库存：${product.productInventory}<span></span></li> 
          <li> 
           <form action="goods-by.do" name="orderform" id="orform" method="post"> 
            <input type="hidden" name="id" id="productId" value="${product.productId}" /> 
            <input type="hidden" id="loginusername" value="${sessionScope.user.userName}" />
           <input type="hidden" id="shuliang" value="1" />
            <p class=""><span class="quantity">数量：</span>
            <span class="quantity-form"><a href="javascript:void(0)" class="jia" onclick="add()">+</a> 
            <input type="text" class="goodnum" value="1" name="num" onblur="pandnum()" />
            <a onclick="reduce()" id="oneA" href="javascript:void(0)" class="jian">-</a></span> 
            </p>
           </form></li>  
         </ul> 
         <h2 class="heji">合计：￥<em class="price">${product.productPrice1}</em></h2>
         <!-- buy--> 
         <c:if test="${sessionScope.user.userName!=null}">
         <div class="addcart_box">
          <a rel="nofollow" href="javascript:void(0)"  onclick="tijiao();return false;" class="dginfo_btn">立刻购买</a> 
          <a rel="nofollow" href="javascript:void(0)" onclick="buy();return false;" class="dginfo_gwc dginfo_btn">加入购物车</a> 
          <!-- 购物车计算浮动层 begin --> 
          <div id="showIncludeCart" style="display:none;"> 
           <a class="buy_pop_close" onclick="jQuery('#showIncludeCart').hide();" title="关闭"></a> 
           <div class="buy_icon"></div> 
           <div class="buy_pop_top">
            <div class="title">
             此商品已成功放入购物车
            </div> 
            <div class="btn_continue"> 
             <div class="pop_btn_r">
              <a onclick="jQuery('#showIncludeCart').hide();return false;" href="javascript:vod(0);">继续购物</a>
             </div> 
             <div class="btn_cart">
              <a href="cart.do">去购物车结算</a>
             </div> 
            </div> 
           </div> 
          </div> 
          <!-- 购物车计算浮动层 over --> 
         </div> 
         </c:if>
         <c:if test="${sessionScope.user.userName==null}">
         <div class="addcart_box" style="z-index: 3">
          <a rel="nofollow" href="javascript:void(0)"  onclick="showBg();return false;" class="dginfo_btn">立刻购买</a> 
          <a rel="nofollow" href="javascript:void(0)" onclick="showBg();return false;" class="dginfo_gwc dginfo_btn">加入购物车</a> 
         <div id="showIncludeCart" style="display:none;"> 
           <a class="buy_pop_close" onclick="jQuery('#showIncludeCart').hide();" title="关闭"></a> 
           <div class="buy_icon"></div> 
           <div class="buy_pop_top">
            <div class="title">
             您还还未登录，请先登录
            </div> 
            <div class="btn_continue"> 
             <div class="pop_btn_r">
              <a onclick="jQuery('#showIncludeCart').hide();return false;" href="javascript:vod(0);">继续浏览</a>
             </div> 
             <div class="btn_cart">
              <a href="login.html">去登录</a>
             </div> 
            </div> 
           </div> 
          </div> 
         </div>
         </c:if>
         
        </div> 
        <!-- 商品参数 结束--> 
       </div> 
        <!-- 商品描述--> 
        <div class="good-tabs"> 
         <ul> 
          <a href="" id="detail_tab" name="__tab_detail_b2c" rel="header1" class="on selected">用户评价</a> 
         </ul>
        </div>
        <div class="tab-line"></div> 
        
        <div id="goods_content" style="height:1050px;"> 
	   	
	   	<c:forEach items="${pinlun.list}" var="pl">
	   	<div class="single" onmouseover="this.className='singlehover'" onmouseout="this.className='single'">
		 <div class="order-detail">用户名：<span>${pl.commentUserName}</span>&nbsp;&nbsp;下单时间：<span>${pl.commentTime }</span>&nbsp;&nbsp;评分：<c:if test="${pl.commentScore==3 }"><span>好评</span></c:if><c:if test="${pl.commentScore==2 }"><span>中评</span></c:if><c:if test="${pl.commentScore==1}"><span>差评</span></c:if></div>
		  <div class="goodlist-wrap">  
		   <div class="three-area" style="width: 100%;">
			  <div class="cos" style="height: 50px;">
			   ${pl.commentContent}
			  </div>
		   </div>   
		  </div>
	   	</div>
	   </c:forEach>
        </div>
        <c:if test="${not empty pinlun }">
       <div class="page"> 
        <div> 
        	
        	<a class="prev" href="shopgoods-${pinlun.firstPage}.do?productId=${product.productId}">«</a>
        	
        	<c:forEach items="${pinlun.navigatepageNums }" var="i">
        		<c:if test="${i==pinlun.pageNum }">
        			<span class="current">${i}</span>
        		</c:if>
        		<c:if test="${i!=pinlun.pageNum}">
        			<a class="num" href="shopgoods-${i}.do?productId=${product.productId}">${i}</a>
        		</c:if>
        	</c:forEach>
        		
        	<a class="next" href="shopgoods-${pinlun.lastPage}.do?productId=${product.productId}">»</a>
         	
         	<span class="rows">共${pinlun.total } 条评价</span>
        </div>
       </div>
       </c:if> 
       </div> 
       <!-- 商品描述结束--> 
       <div class="details_right" ">
       <dl>
        <dt>
         你可能喜欢
        </dt>
       	<c:forEach items="${xihuan }" var="xgG">
        <dd>
         <a class="details_right_img" href="shopgoods-1.do?productId=${xgG.productId}" title="${xgG.productName }"><img src="${xgG.productImgs }" alt="${xgG.productName }" style="display: inline-block;" /></a>
         <a href="shopgoods-1.do?productId=${xgG.productId}" class="details_right_title" title="${xgG.productName }">${xgG.productName }</a>
         <span class="fwb mcm_title_price">￥<span class="red">${xgG.productPrice1 }</span></span>
        </dd>
        </c:forEach>		
       </dl>
      </div> 
      </div> 
     </div> 
    </div> 
<script type="text/javascript">

function showBg() { 
    $("#showIncludeCart").css({
        display:"block"
    });
}

//购买
function tijiao() { 
	$("#orform").submit();
}

//加购物车
function buy()
{
	var productId=$("#productId").val();
	var userName=$("#loginusername").val();
	var goodsnum=$(".goodnum").val();//数量
	var goodsprice=$(".price").eq(1).text();//价格
	var goodsname=$(".dginfo_h2").text();//名称

			$.ajax({
				type:'post', //传送的方式,get/post
				url:'add-cart.do', //发送数据的地址
				 data:{
					 productId:productId,userName:userName,goodsnum:goodsnum,goodsprice:goodsprice,goodsname:goodsname
				 },
				 dataType: "json",
				});
			showBg();
}

 //增加数量
function add() {

 var num = $(".goodnum").val(); 
 var danjia=$(".price").eq(0).text();//价格
 var goodsprice=$(".price").eq(1).text();    
 num++;
 if(num>"${product.productInventory}"){
	 $(".goodnum").val("${product.productInventory}");
	/*  $("#shuliang").val("${product.productInventory}"); */
	 }else{
		 $(".goodnum").val(num);
		 /* $("#shuliang").val(num); */
		 $(".price").eq(1).text(danjia*num);
		 }
 
}
//减少数量
function reduce() {

 var num = $(".goodnum").val(); 
 var danjia=$(".price").eq(0).text();//价格
 var goodsprice=$(".price").eq(1).text();    

if(num>1)  
      { num--; 
    	$(".goodnum").val(num);
    	/* $("#shuliang").val(num); */
    	$(".price").eq(1).text(goodsprice-danjia);
      }

}  
    </script> 
   </div> 
   <script type="text/javascript" charset="utf-8" src="/shop/js/shop-menudown.js"></script>
 <%@ include file="/shop/jsps/footer.jsp" %>
  </body>
</html>